package com.pdg.mcplugin.ranger.conversations;

import java.util.HashMap;
import java.util.Map;

import org.bukkit.conversations.Conversation;
import org.bukkit.entity.Player;

import com.pdg.mcplugin.common.baseclasses.ConversationFactoryBase;
import com.pdg.mcplugin.common.conversation.SimpleConversationAbandonedListener;
import com.pdg.mcplugin.common.conversation.SimpleConversationPrefix;
import com.pdg.mcplugin.ranger.Ranger;

public class RangerConversationFactory extends ConversationFactoryBase<Ranger>{

	public RangerConversationFactory(Ranger thePlugin) {
		super(thePlugin);
	}
	
	public void startRenameConversation(Player thePlayer,String theLocationName){
	    final Map<Object, Object> map = new HashMap<Object, Object>();
	    map.put(RenamePrompt.KEY_PUBLIC, false);
	    map.put(RenamePrompt.KEY_PLAYER, thePlayer.getName());
	    map.put(RenamePrompt.KEY_WORLD, thePlayer.getWorld().getName());
	    map.put(RenamePrompt.KEY_PLACENAME, theLocationName);
	    Conversation conv = getPlugin().getConversationFactory()
	            .withFirstPrompt(new RenamePrompt(getPlugin()))
	            .withPrefix(new SimpleConversationPrefix(""))
	            .withInitialSessionData(map)
	            .withLocalEcho(false)
	            .withModality(true)
	            .buildConversation(thePlayer);
	    conv.addConversationAbandonedListener(new SimpleConversationAbandonedListener());
	    conv.begin();
	}
	public void startPublicRenameConversation(Player thePlayer,String theLocationName){
	    final Map<Object, Object> map = new HashMap<Object, Object>();
	    map.put(RenamePrompt.KEY_PUBLIC, true);
	    map.put(RenamePrompt.KEY_PLAYER, thePlayer.getName());
	    map.put(RenamePrompt.KEY_WORLD, thePlayer.getWorld().getName());
	    map.put(RenamePrompt.KEY_PLACENAME, theLocationName);
	    Conversation conv = getPlugin().getConversationFactory()
	            .withFirstPrompt(new RenamePrompt(getPlugin()))
	            .withPrefix(new SimpleConversationPrefix(""))
	            .withInitialSessionData(map)
	            .withLocalEcho(false)
	            .withModality(true)
	            .buildConversation(thePlayer);
	    conv.addConversationAbandonedListener(new SimpleConversationAbandonedListener());
	    conv.begin();
	}
	
}
